﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace KD.Sms
{
    public partial class frmWaring : Form
    {
        private List<string> E_List = new List<string>();
        public frmWaring()
        {
            InitializeComponent();
        }

        public frmWaring(string str)
        {
            InitializeComponent();
            E_List.Add(str);
        }

        public frmWaring(List<string> list)
        {
            InitializeComponent();
            E_List = list;
            //foreach (string _strMsg in E_List)
            //{
            //    RicMsgShow(ricMsg,_strMsg);
            //}
        }

        private delegate void ApplicationInfomation(RichTextBox ricMsg, string _msg);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public void RicMsgShow(RichTextBox ricMsg, string _message)
        {
            //在线程里以安全方式调用控件
            if (ricMsg.InvokeRequired)
            {
                ApplicationInfomation _MyInvoke = new ApplicationInfomation(RicMsgShow);
                ricMsg.Invoke(_MyInvoke, new object[] { ricMsg, _message });
            }
            else
            {
                ricMsg.AppendText(_message + "\r\n");
            }
        }



        private void frmWaring_Load(object sender, EventArgs e)
        {
            //Thread th = new Thread(new ThreadStart(DoSetEnableAndText)) { IsBackground = true };
            //th.Start();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void DoSetEnableAndText()
        {
            UI.FormHelper.SetControlEnabled(btnSure, false);
            for (int i = 5; i >= 0; i--)
            {
                if (i > 0)
                {
                    UI.FormHelper.SetControlText(btnSure, string.Format("确 定({0})", i));
                    System.Threading.Thread.Sleep(1000);
                }
                else
                    UI.FormHelper.SetControlText(btnSure, "确 定");
            }
            UI.FormHelper.SetControlEnabled(btnSure, true);
        }

        private void frmWaring_FormClosing(object sender, FormClosingEventArgs e)
        {
        }
    }
}
